A Behavioral Subtyping, Specification Inheritance, and Modular Reasoning
نویسندگان
چکیده
Verification of a dynamically-dispatched method call, E .m(), seems to depend on E ’s dynamic type. To avoid case analysis and allow incremental development, object-oriented program verification uses supertype abstraction. That is, one reasons about E .m() using m’s specification for E ’s static type. Supertype abstraction is valid when each subtype in the program is a behavioral subtype. This paper formalizes supertype abstraction and behavioral subtyping for a Java-like sequential language with mutation, and proves that behavioral subtyping is both necessary and sufficient for the validity of supertype abstraction. Specification inheritance, as in JML, is also formalized and proved to entail behavioral subtyping.
منابع مشابه
JML's Rich, Inherited Specifications for Behavioral Subtypes
The Java Modeling Language (JML) is used to specify detailed designs for Java classes and interfaces. It has a particularly rich set of features for specifying methods. This paper describes those features, with particular emphasis on the features related to specification inheritance. It shows how specification inheritance in JML forces behavioral subtyping, through a discussion of semantics and...
متن کاملBehavioral Subtyping is Equivalent to Modular Reasoning for Object-oriented Programs
Behavioral subtyping is an established idea that enables modular reasoning about behavioral properties of object-oriented programs. It requires that syntactic subtypes are behavioral refinements. It validates reasoning about a dynamically-dispatched method call, say E .m(), using the specification associated with the static type of the receiver expression E . For languages with references and m...
متن کاملLazy Behavioral Subtyping
Inheritance combined with late binding allows flexible code reuse but complicates formal reasoning significantly, as a method call’s receiver class is not statically known. This is especially true when programs are incrementally developed by extending class hierarchies. This paper develops a novel method to reason about late bound method calls. In contrast to traditional behavioral subtyping, r...
متن کاملBehavioral Subtyping in Object-Oriented Languages
Modularity and code reuse are two important features of object-oriented programming. Modularity means that adding new components does not require reveri cation or respeci cation of existing components. A common form of reuse in objectoriented programs is to add new subtypes to existing types and to invoke already existing procedures with objects of these new types. In such cases, behavior of pr...
متن کاملPractical Strengthening of Preconditions
This paper takes a closer look at behavioral subtyping in the context of concurrency, by considering an example of subtyping of a concurrent datastructure taken from sensor networks. Akin to the extension of a state-machine, this example illustrates conflicts caused by the interference of concurrency and inheritance. In short, the extension consists in declaring additional fields in a subclass,...
متن کامل